steps360=400.0
degperstep=360.0 / steps360
TIMERPERIOD=1.0e-7
tregmin=65535
totaltime=1.0
vi = degperstep / (TIMERPERIOD * tregmin)
vf=1440.0

set macros
NOYTICS = "set format y ''; unset ylabel"
YTICS = "set format y '%1.1f'; set ylabel ''"

# Linear form
lvnorm(t) = t

# Sigmoid form
ef=10 # shape of the sigmoid, larger ef makes it sharper
svnorm(t)=1 / (1 + exp(-(ef*t - (ef/2))))



#set terminal wxt font "/usr/share/fonts/dejavu/DejaVuSans.ttf" 8 size 640,240
#set terminal png font "/usr/share/fonts/dejavu/DejaVuSans.ttf" 8 size 640,240
#set output "normalized.png"

#set multiplot layout 1, 2 rowsfirst

#@YTICS
#set key outside bottom center title 'Linear: v(t) = t'
#plot [t=0:1] lvnorm(t) title ''
#@NOYTICS
#set key outside bottom center title 'S-shape: v(t) = 1 / 1 + exp(-(sh*t - (sh/2)))'
#plot [t=0:1] svnorm(t) title ''

#set output "speeds.png"
#vi=1440
#vf=degperstep / (TIMERPERIOD * tregmin)
lv(t)=vi + ((vf-vi)*(t/totaltime))
lvd(t)=vf + ((vi-vf)*(1 - t/totaltime))
sv(t) = vi + (vf - vi) * (1 / (1+exp(-(((ef/totaltime)*t-(ef/2))))))
svd(t) = vf + (vi - vf) * (1 / (1+exp(-((ef - ((ef/totaltime)*t)) - (ef/2)))))
#@YTICS
#set key outside bottom center title 'Linear speed profile'
#plot [t=0:totaltime] lvd(t) title ''
#@NOYTICS
#set key outside bottom center title 'S-shape speed profile'
#plot [t=0:totaltime] svd(t) title ''

# Steps
ls(t)=vi*t + ((vf-vi)*((t*t)/(2*totaltime)))
ss(t)=vi*t + (vf-vi)*(totaltime/ef)*log(1+exp((((ef/totaltime)*t-(ef/2)))))
# Period in timer unit
lp(t)=(degperstep*1e7) / lv(t) 
sp(t)=(degperstep*1e7) / sv(t) 
#plot [t=0:totaltime] lv(t) , floor(ls(t)) with histeps
#plot [t=0:totaltime]  lp(t)
#plot [t=0:totaltime] sv(t) , floor(ss(t)) with histeps
#plot [t=0:totaltime]  sp(t)
set parametric
#plot [t=0:totaltime] floor(ls(t)),lv(t)
#plot [t=0:totaltime] floor(ls(t)),lp(t)
#plot [t=0:totaltime] floor(ss(t)),sv(t)
plot [t=0:totaltime] floor(ss(t)),sp(t), floor(ls(t)), lp(t)

#unset multiplot

unset macros